home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume11 / starchart / part23 < prev    next >
Encoding:
Text File  |  1990-03-25  |  35.6 KB  |  1,412 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i051: starchart 3.2 Part 23/32
  3. from: ccount@ATHENA.MIT.EDU
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 11, Issue 51
  7. Submitted-by: ccount@ATHENA.MIT.EDU
  8. Archive-name: starchart/part23
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 23 (of 32)."
  17. # Contents:  starchart/starmain.c
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'starchart/starmain.c' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'starchart/starmain.c'\"
  21. else
  22. echo shar: Extracting \"'starchart/starmain.c'\" \(33377 characters\)
  23. sed "s/^X//" >'starchart/starmain.c' <<'END_OF_FILE'
  24. X/*
  25. X * starmain.c, starchart.c without routines moved to starsupp.c
  26. X * starchart.c -- version 2, September 1987
  27. X *        revision 2.1 December, 1987
  28. X *        revision 3.2 February 1990
  29. X * contact Craig Counterman, email: ccount@athena.mit.edu
  30. X *
  31. X * Portions Copyright (c) 1987 by Alan Paeth (awpaeth@watcgl)
  32. X *
  33. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  34. X *
  35. X * This software may be redistributed freely, not sold.
  36. X * This copyright notice and disclaimer of warranty must remain
  37. X *    unchanged. 
  38. X *
  39. X * No representation is made about the suitability of this
  40. X * software for any purpose.  It is provided "as is" without express or
  41. X * implied warranty, to the extent permitted by applicable law.
  42. X *
  43. X * DISCLAIMER OF WARRANTY
  44. X * ----------------------
  45. X * The author  disclaims all warranties  with regard to  this software to
  46. X * the   extent  permitted  by applicable   law,  including all   implied
  47. X * warranties  of merchantability  and  fitness. In  no event shall   the
  48. X * author be liable for any special, indirect or consequential damages or
  49. X * any  damages whatsoever resulting from  loss of use, data or  profits,
  50. X * whether in an action of contract, negligence or other tortious action,
  51. X * arising  out of  or in connection with the  use or performance of this
  52. X * software.
  53. X *
  54. X */
  55. X
  56. X/*
  57. X ! Version 2 modification authors:
  58. X !
  59. X !   [a] Petri Launiainen, pl@intrin.FI (with Jyrki Yli-Nokari, jty@intrin.FI)
  60. X !   [b] Bob Tidd, inp@VIOLET.BERKELEY.EDU
  61. X !   [c] Alan Paeth, awpaeth@watcgl
  62. X !
  63. X */
  64. X
  65. Xstatic char rcsid[]="$Header: starmain.c,v 2.15 90/03/10 15:31:37 ccount Exp $";
  66. X
  67. X#include <stdio.h>
  68. X#include <math.h>
  69. X#ifndef SYSV
  70. X#include <strings.h>
  71. X#else
  72. X#include <string.h>
  73. X#endif
  74. X#include <ctype.h>
  75. X
  76. X#include "star3.h"
  77. X#include "parse_input.h"
  78. X
  79. X#ifndef READMODE
  80. X#define READMODE "r"
  81. X#endif
  82. X#define OPENFAIL 0
  83. X#define LINELEN 82
  84. X
  85. X#ifndef MAXPATHLEN
  86. X#define MAXPATHLEN 1025
  87. X#endif
  88. X
  89. X/* PI / 180 = .0174532925199 */
  90. X#define DCOS(x) (cos((x)*.0174532925199))
  91. X#define DSIN(x) (sin((x)*.0174532925199))
  92. X#define DTAN(x) (tan((x)*.0174532925199))
  93. X#define DASIN(x) (asin(x)/.0174532925199)
  94. X#define DATAN2(x,y) (atan2(x,y)/.0174532925199)
  95. X#define MAX(a,b) ((a)>(b)?(a):(b))
  96. X#define MIN(a,b) ((a)<(b)?(a):(b))
  97. X
  98. X/*
  99. X * default datasets are local, unless defined in Makefile
  100. X */
  101. X
  102. X#ifndef STARFILE
  103. X#define STARFILE    "./yale.star"
  104. X#endif
  105. X#ifndef STARFTYPE
  106. X#define STARFTYPE LINEREAD
  107. X#endif
  108. X
  109. X#ifndef INDEXFILE
  110. X#define INDEXFILE    "./index.indx"
  111. X#endif
  112. X#ifndef INDEXFTYPE
  113. X#define INDEXFTYPE INDEXTYPE
  114. X#endif
  115. X
  116. X#ifndef PLANETFILE
  117. X#define PLANETFILE    "./planet.star"
  118. X#endif
  119. X#ifndef PLANETFTYPE
  120. X#define PLANETFTYPE LINEREAD
  121. X#endif
  122. X
  123. X#ifndef NEBFILE
  124. X#define NEBFILE        "./neb.star"
  125. X#endif
  126. X#ifndef NEBFTYPE
  127. X#define NEBFTYPE LINEREAD
  128. X#endif
  129. X
  130. X#ifndef BOUNDFILE
  131. X#define BOUNDFILE    "./boundaries.star"
  132. X#endif
  133. X#ifndef BOUNDFTYPE
  134. X#define BOUNDFTYPE LINEREAD
  135. X#endif
  136. X
  137. X#ifndef PATTERNFILE
  138. X#define PATTERNFILE    "./pattern.star"
  139. X#endif
  140. X#ifndef PATTFTYPE
  141. X#define PATTFTYPE LINEREAD
  142. X#endif
  143. X
  144. X#ifndef CNAMEFILE
  145. X#define CNAMEFILE    "./cnames.star"
  146. X#endif
  147. X#ifndef CNAMEFTYPE
  148. X#define CNAMEFTYPE LINEREAD
  149. X#endif
  150. X
  151. X#ifndef CONSTFILE
  152. X#define CONSTFILE    "./con.locs"
  153. X#endif
  154. X
  155. X#ifndef RCFILE
  156. X#define RCFILE    "./.starrc"
  157. X#endif
  158. X
  159. X
  160. X/* arguments */
  161. Xint g_argc;
  162. Xchar **g_argv;
  163. X
  164. X/* Globals read from command line or set by D_userinput */
  165. Xchar *progname;
  166. Xdouble ra, de, sc;
  167. Xchar *title = "";
  168. Xdouble all_lbllim, all_maglim, all_gklim;
  169. Xint use_lbllim = FALSE, use_maglim = FALSE, use_gklim = FALSE;
  170. X
  171. Xint user_interact = FALSE;
  172. X
  173. Xint precess = FALSE;
  174. Xdouble to_precess = 2000.0;
  175. X
  176. Xdouble all_vmin, all_vmax;
  177. Xint use_vmin = FALSE;
  178. Xint nomaglbls = FALSE;
  179. X
  180. Xdouble all_rstep, all_dstep;
  181. Xint use_rstep = FALSE;
  182. Xint no_ra_grid = FALSE;
  183. Xint no_dec_grid = FALSE;
  184. Xdouble all_rstrt = 0.0, all_dstrt = 0.0;
  185. X
  186. Xint all_invert = FALSE;
  187. X
  188. Xint chart_type = THREEPART;
  189. X
  190. Xint all_proj_mode = SANSONS;
  191. X
  192. Xchar *rcfile = RCFILE;
  193. X
  194. Xchar *constfile = CONSTFILE;
  195. Xchar *boundfile = BOUNDFILE;
  196. Xchar boundftype = BOUNDFTYPE;
  197. Xchar *patternfile = PATTERNFILE;
  198. Xchar pattftype = PATTFTYPE;
  199. Xchar *cnamefile = CNAMEFILE;
  200. Xchar cnameftype = CNAMEFTYPE;
  201. Xchar *mapfiles[MAXMAPFILES];
  202. Xint mapftypes[MAXMAPFILES];
  203. Xint nummapfiles;
  204. X
  205. Xmapwindow *mapwin[MAXWINDOWS];
  206. Xint numwins;
  207. X
  208. Xint cur_function;
  209. Xint cur_map_type;
  210. Xint cur_map_tag;
  211. Xchar *cur_tag_field;
  212. Xchar *cur_file_name = "";
  213. Xmapwindow *cur_win;
  214. X
  215. Xint read_mapwin_file;
  216. Xint write_mapwin_file;
  217. Xchar mapwin_file[MAXPATHLEN];
  218. X
  219. X
  220. X/* read file function indirection to allow for use of alternate file readers */
  221. Xint readstar();
  222. Xint buf_readstar();
  223. X/* Macintosh MPW currently doesn't support buf_readstar */
  224. X#ifndef macintosh
  225. Xint (*readfile)() = buf_readstar;
  226. X#else
  227. Xint (*readfile)() = readstar;
  228. X#endif
  229. X
  230. X/* Readstar globals */
  231. Xdouble obj_lat, obj_lon, obj_mag;
  232. Xchar obj_type[] ="SS", obj_color[3], obj_label[3];
  233. Xchar obj_constell[3], obj_name[LINELEN];
  234. Xchar *obj_commnt, fileline[LINELEN];
  235. X
  236. X/* xform globals */
  237. Xextern double xf_west, xf_east, xf_north, xf_south, xf_bottom;
  238. Xextern int xf_xcen, xf_ycen, xf_ybot;
  239. Xextern int xf_w_left, xf_w_right, xf_w_top, xf_w_bot;
  240. X
  241. Xextern double xf_c_scale;
  242. X
  243. X/* Other globals */
  244. Xint all_layer[MAXLAYRS];
  245. Xint numlayers;
  246. X
  247. X/* storage area big enough for inputs */
  248. Xchar a_title[MAXPATHLEN];
  249. Xchar a_starfile[MAXPATHLEN];
  250. Xchar a_indexfile[MAXPATHLEN];
  251. Xchar a_planetfile[MAXPATHLEN];
  252. Xchar a_nebfile[MAXPATHLEN];
  253. Xchar a_constfile[MAXPATHLEN];
  254. Xchar a_boundfile[MAXPATHLEN];
  255. Xchar a_patternfile[MAXPATHLEN];
  256. Xchar a_cnamefile[MAXPATHLEN];
  257. Xchar a_userfile[MAXMAPFILES][MAXPATHLEN];
  258. X
  259. X
  260. X/* externals */
  261. Xextern mapwindow fullpage;
  262. Xextern mapwindow mainmap;
  263. Xextern mapwindow thumbmap;
  264. Xextern int htick_lim, htext_lim;
  265. Xextern int htext_xoff, htext_yoff;
  266. Xextern int vtick_lim, vtext_lim;
  267. Xextern int vtext_xoff, vtext_yoff;
  268. X
  269. X/* the code */
  270. Xmain(argc, argv)
  271. X     int argc;
  272. X     char *argv[];
  273. X{
  274. X  int i, j, k;
  275. X  int imap;
  276. X  int ilay;
  277. X  mapwindow *win;
  278. X#define COMMBUFLEN 1000
  279. X  char commbuf[COMMBUFLEN+2];
  280. X  FILE *mfile;
  281. X
  282. X  /* Set global arguments */
  283. X  g_argc = argc;
  284. X  g_argv = argv;
  285. X  progname = g_argv[0];
  286. X  
  287. X  /* Set defaults */
  288. X  ra = 0.0;
  289. X  de = 0.0;
  290. X  sc = 15.0;
  291. X
  292. X  mapfiles[YALEF] = a_starfile;
  293. X  strcpy(a_starfile, STARFILE);
  294. X  mapfiles[INDXF] = a_indexfile;
  295. X  strcpy(a_indexfile, INDEXFILE);
  296. X  mapfiles[PLANF] = a_planetfile;
  297. X  strcpy(a_planetfile, PLANETFILE);
  298. X  mapfiles[NEBF] = a_nebfile;
  299. X  strcpy(a_nebfile, NEBFILE);
  300. X  mapftypes[YALEF] = STARFTYPE;
  301. X  mapftypes[INDXF] = INDEXFTYPE;
  302. X  mapftypes[PLANF] = PLANETFTYPE;
  303. X  mapftypes[NEBF] = NEBFTYPE;
  304. X  nummapfiles = NUMFS;
  305. X  
  306. X  for (i = 0; i < MAXUFILES; i++) {
  307. X    mapfiles[NUMFS+i] = a_userfile[i];
  308. X    mapftypes[NUMFS+i] = LINEREAD;
  309. X  }
  310. X  
  311. X  all_layer[0] = OUTLINE;
  312. X  all_layer[1] = RA_GRID;
  313. X  all_layer[2] = DEC_GRID;
  314. X  all_layer[3] = ECLIPTIC;
  315. X  all_layer[4] = BOUNDARIES;
  316. X  all_layer[5] = PATTERNS;
  317. X  all_layer[6] = CONSTLNAMES;
  318. X  all_layer[7] = ALLFILES;
  319. X  all_layer[8] = LEGENDS;
  320. X  numlayers = 9;
  321. X  
  322. X  /* Read .starrc or other rc file */
  323. X  if (!rc_read(rcfile));
  324. X  /* couldn't open rcfile, but that's OK */
  325. X  
  326. X  /* Read command line: may override .starrc */
  327. X  if (!commandline());
  328. X  /* no arguments, but that's OK */
  329. X  
  330. X#ifdef INTERACTIVE_CONTROL
  331. X  while (D_userinput()) {
  332. X#endif
  333. X  
  334. X  /* set up maps */
  335. X  switch (chart_type) {
  336. X  case THREEPART:
  337. X    mapwin[0] = &mainmap;
  338. X/* it's okay to have thumbmap in stereographic mode now
  339. X    if (all_proj_mode == STEREOGR) {
  340. X      numwins = 1;
  341. X    } else {
  342. X      mapwin[1] = &thumbmap;
  343. X      numwins = 2;
  344. X    }
  345. X*/
  346. X    mapwin[1] = &thumbmap;
  347. X    numwins = 2;
  348. X    break;
  349. X  case FULLPAGE:
  350. X    mapwin[0] = &fullpage;
  351. X    numwins = 1;
  352. X    break;
  353. X  default:
  354. X    numwins = 0;
  355. X    break;
  356. X  }
  357. X  
  358. X      
  359. X  for (i = 0; i < numwins; i++) {
  360. X    if (use_maglim) 
  361. X      mapwin[i]->maglim = all_maglim;
  362. X
  363. X    if (use_lbllim) mapwin[i]->lbllim = all_lbllim;
  364. X    if (use_gklim) mapwin[i]->gklim = all_gklim;
  365. X
  366. X    mapwin[i]->racen = ra;
  367. X    mapwin[i]->dlcen = de;
  368. X    
  369. X    mapwin[i]->scale = sc;
  370. X
  371. X    mapwin[i]->proj_mode = all_proj_mode;
  372. X    
  373. X   
  374. X    if (use_rstep) {
  375. X      mapwin[i]->draw_ragrid = TRUE;
  376. X      mapwin[i]->draw_decgrid = TRUE;
  377. X      mapwin[i]->ra_step = all_rstep;
  378. X      mapwin[i]->dec_step = all_dstep;
  379. X      mapwin[i]->ra_strt = all_rstrt;
  380. X      mapwin[i]->dec_strt = all_dstrt;
  381. X    }
  382. X    
  383. X    if (no_ra_grid) mapwin[i]->draw_ragrid = FALSE;
  384. X    if (no_dec_grid) mapwin[i]->draw_decgrid = FALSE;
  385. X
  386. X    if (all_invert) mapwin[i]->invert = TRUE;
  387. X    
  388. X    for (j =0; j < numlayers; j++)
  389. X      mapwin[i]->layer[j] = all_layer[j];
  390. X    mapwin[i]->nlayers= numlayers;
  391. X
  392. X    for (j =0; j < nummapfiles; j++) {
  393. X      mapwin[i]->file[j].name = mapfiles[j];
  394. X      mapwin[i]->file[j].type = mapftypes[j];
  395. X      mapwin[i]->file[j].maglim = mapwin[i]->maglim;
  396. X      mapwin[i]->file[j].lbllim = mapwin[i]->lbllim;
  397. X      mapwin[i]->file[j].gklim = mapwin[i]->gklim;
  398. X
  399. X      if (use_vmin)  {
  400. X    mapwin[i]->file[j].draw_maglbl = TRUE;
  401. X    mapwin[i]->file[j].maglmin = all_vmin;
  402. X    mapwin[i]->file[j].maglmax = all_vmax;
  403. X      }
  404. X      if (nomaglbls) mapwin[i]->file[j].draw_maglbl = FALSE;
  405. X    }
  406. X    mapwin[i]->numfiles = nummapfiles;
  407. X  }
  408. X      
  409. X  /* Give driver a chance to change the mapwins */
  410. X  fix_mapwin();
  411. X#ifdef INTERACTIVE_CONTROL
  412. X  if (user_interact)
  413. X    D_mapwininput();
  414. X#endif
  415. X
  416. X      
  417. X  /* Begin chart */
  418. X  if (!D_open())
  419. X    die("couldn't open device", "");
  420. X
  421. X  k = 0;
  422. X  commbuf[0] = '\0';
  423. X  for (i = 0; (i < argc) && (k < COMMBUFLEN); i++) {
  424. X    sprintf(&commbuf[strlen(commbuf)], "%s ", argv[i]);
  425. X  }
  426. X  D_comment(commbuf);
  427. X
  428. X  /* Write the current settings to mapwin file */
  429. X  /* Must be done here to allow D_open to change settings, esp. window size */
  430. X  if ((write_mapwin_file)  && ((mfile = fopen(mapwin_file, "w")) != NULL)) {
  431. X    write_mfile(mfile);
  432. X    fclose(mfile);
  433. X  }
  434. X  
  435. X  if (precess)
  436. X    initprecess(to_precess);
  437. X
  438. X
  439. X  D_comment("Start");
  440. X
  441. X  /* Draw the chart */
  442. X  /* For each map
  443. X       for each layer
  444. X         draw the layer */
  445. X  for (imap = 0; imap < numwins; imap++) {
  446. X#ifdef INTERACTIVE_CONTROL
  447. X  if (user_interact)
  448. X    if (D_break()) break;
  449. X#endif
  450. X    win = mapwin[imap];
  451. X    if (!chartparms(win)) continue;
  452. X    if (!initxform(win)) continue;    /* initialize xform before using it */
  453. X
  454. X    cur_map_type = win->map_type;
  455. X    cur_map_tag = win->tag;
  456. X    cur_tag_field = win->tag_field;
  457. X    cur_win = mapwin[imap];
  458. X
  459. X    for (ilay = 0; ilay < win->nlayers; ilay++) {
  460. X#ifdef INTERACTIVE_CONTROL
  461. X      if (user_interact)
  462. X    if (D_break()) break;
  463. X#endif
  464. X      switch (win->layer[ilay]) {
  465. X      case OUTLINE:
  466. X    D_comment("OUTLINE");
  467. X    chartoutline(win);
  468. X    break;
  469. X      case RA_GRID:
  470. X    D_comment("RA_GRID");
  471. X    chartragrid(win);
  472. X    break;
  473. X      case DEC_GRID:
  474. X    D_comment("DEC_GRID");
  475. X    chartdecgrid(win);
  476. X    break;
  477. X      case ECLIPTIC:
  478. X    D_comment("ECLIPTIC");
  479. X    chartecliptic(win);
  480. X    break;
  481. X      case BOUNDARIES:
  482. X    D_comment("BOUNDARIES");
  483. X    chartboundaries(win);
  484. X    break;
  485. X      case PATTERNS:
  486. X    D_comment("PATTERNS");
  487. X    chartpatterns(win);
  488. X    break;
  489. X      case CONSTLNAMES:
  490. X    D_comment("CONSTLNAMES");
  491. X    chartconstlnames(win);
  492. X    break;
  493. X      case ALLFILES:
  494. X    D_comment("ALLFILES");
  495. X    chartmain(win, ALLFILES);
  496. X    break;
  497. X      case ALLGLYPHS:
  498. X    D_comment("ALLGLYPHS");
  499. X    chartmain(win, ALLGLYPHS);
  500. X    break;
  501. X      case ALLNAMES:
  502. X    D_comment("ALLNAMES");
  503. X    chartmain(win, ALLNAMES);
  504. X    break;
  505. X      case ALLMAGLBLS:
  506. X    D_comment("ALLMAGLBLS");
  507. X    chartmain(win, ALLMAGLBLS);
  508. X    break;
  509. X      case ALLVECTORS:
  510. X    D_comment("ALLVECTORS");
  511. X    chartmain(win, ALLVECTORS);
  512. X    break;
  513. X      case ALLAREAS:
  514. X    D_comment("ALLAREAS");
  515. X    chartmain(win, ALLAREAS);
  516. X    break;
  517. X      case LEGENDS:
  518. X    D_comment("LEGENDS");
  519. X    chartlegend(win);
  520. X    break;
  521. X      }
  522. X    }
  523. X  }
  524. X  
  525. X  /* Done chart: close and exit */
  526. X  D_comment("Close");
  527. X  D_close();
  528. X
  529. X#ifdef INTERACTIVE_CONTROL
  530. X  }
  531. X#endif
  532. X
  533. X
  534. X  exit(0);
  535. X}
  536. X
  537. X
  538. Xcommandline()
  539. X{
  540. X  int j, k;
  541. X  double varmag, varrange;
  542. X  int loc_argc;
  543. X/*
  544. X * check command line style
  545. X */
  546. X  if (g_argc == 1) return (FALSE);
  547. X
  548. X  if  ( (g_argv[1][0] == '-') && g_argv[1][1] ) {
  549. X/*
  550. X * new style command line (using flags)
  551. X */
  552. X    loc_argc = g_argc;        /* in case D_control_args changes g_argc */
  553. X    for (j=1; j<loc_argc; j++) {
  554. X      if (g_argv[j][0] != '-') die("unknown argument - '%s'", g_argv[j]);
  555. X      switch (g_argv[j][1]) {
  556. X
  557. X#ifdef INTERACTIVE_CONTROL
  558. X      case 'u': user_interact = TRUE; break;
  559. X#endif
  560. X
  561. X      case 'r': ra = htod(g_argv[++j])*15.0; break; /* hrs -> deg */
  562. X      case 'd': de = htod(g_argv[++j]); break;
  563. X      case 's': sc = atof(g_argv[++j]); break;
  564. X
  565. X      case 'm': all_maglim = (double)(atof(g_argv[++j]));
  566. X    use_maglim = TRUE; break;
  567. X      case 'l': all_lbllim = (double)(atof(g_argv[++j]));
  568. X    use_lbllim = TRUE; break;
  569. X      case 'g': all_gklim  = (double)(atof(g_argv[++j]));
  570. X    use_gklim = TRUE; break;
  571. X
  572. X      case 'p':
  573. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-'))
  574. X      {
  575. X        if (k = tr_pmode(g_argv[++j])) {
  576. X          all_proj_mode = k;
  577. X        }
  578. X      }
  579. X    else all_proj_mode = STEREOGR;
  580. X    break;
  581. X
  582. X      case 'b': chart_type = FULLPAGE; break;
  583. X
  584. X      case 'i': all_invert = TRUE; break;
  585. X
  586. X      case 't': title = g_argv[++j]; break;
  587. X
  588. X    /* can be filename filetype  or just  filename */
  589. X      case 'y':
  590. X    strcpy(mapfiles[YALEF], g_argv[++j]);
  591. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  592. X        tr_fty(g_argv[j+1]))
  593. X      mapftypes[YALEF] = tr_fty(g_argv[++j]);
  594. X    break;
  595. X      case 'h':  strcpy(mapfiles[INDXF], g_argv[++j]); break;
  596. X      case 'n':
  597. X    strcpy(mapfiles[NEBF], g_argv[++j]);
  598. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  599. X        tr_fty(g_argv[j+1]))
  600. X      mapftypes[NEBF] = tr_fty(g_argv[++j]);
  601. X    break;
  602. X      case 'w':
  603. X    strcpy(mapfiles[PLANF], g_argv[++j]);
  604. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  605. X        tr_fty(g_argv[j+1]))
  606. X      mapftypes[PLANF] = tr_fty(g_argv[++j]);
  607. X    break;
  608. X      case 'f': 
  609. X    if (nummapfiles == MAXMAPFILES) {
  610. X      fprintf(stderr, "Too many user files\n");
  611. X      j++;
  612. X    } else {
  613. X      strcpy(mapfiles[nummapfiles], g_argv[++j]);
  614. X      if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  615. X          tr_fty(g_argv[j+1]))
  616. X        mapftypes[nummapfiles] = tr_fty(g_argv[++j]);
  617. X      else
  618. X        mapftypes[nummapfiles] = LINEREAD;
  619. X      nummapfiles++;
  620. X    }
  621. X    break;
  622. X
  623. X      case 'c':    /* could be -c con or -c con con.locs */
  624. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-'))
  625. X      {
  626. X        constfile = g_argv[j+2];
  627. X        findconst(g_argv[++j]);
  628. X        j++;
  629. X      }
  630. X    else findconst(g_argv[++j]);
  631. X    break;
  632. X    
  633. X    
  634. X      case 'v':
  635. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-')
  636. X        && (g_argv[j+1][0] != '-')) {
  637. X      varmag = atof(g_argv[j+1]);
  638. X      varrange = atof(g_argv[j+2]);
  639. X      use_vmin = TRUE;
  640. X      all_vmin = varmag - varrange;
  641. X      all_vmax = varmag + varrange;
  642. X      j += 2;
  643. X    } else die("Need varmag varrange for -v","");
  644. X    break;
  645. X
  646. X      case 'x':
  647. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-')
  648. X        && (g_argv[j+1][0] != '-')) {
  649. X      use_rstep = TRUE;
  650. X      all_rstep = htod(g_argv[j+1])*15.0;
  651. X      all_dstep = htod(g_argv[j+2]);
  652. X      if (((j+4) < loc_argc)
  653. X          && (!isalpha(g_argv[j+3][1]))
  654. X          && (!isalpha(g_argv[j+4][1]))) {
  655. X        all_rstrt = htod(g_argv[j+3])*15.0;
  656. X        all_dstrt = htod(g_argv[j+4]);
  657. X        j += 4;
  658. X      } else
  659. X        j += 2;
  660. X    } else die("Need ra_step de_step for -x","");
  661. X    break;
  662. X
  663. X      case 'e':
  664. X    if (!rc_read(g_argv[++j]))
  665. X      fprintf(stderr,
  666. X          "%s: error, couldn't read rc file '%s'\n",
  667. X          progname, g_argv[j]);
  668. X    break;
  669. X
  670. X      case 'a':
  671. X    D_control_arg(g_argv[++j]);
  672. X    break;
  673. X    
  674. X      default:
  675. X    if (!ident_arg(&j))
  676. X      die("unknown switch - '%s'", g_argv[j]);
  677. X    break;
  678. X      }
  679. X      if (j == loc_argc) die("trailing command line flag - '%s'", g_argv[j-1]);
  680. X    }
  681. X  }
  682. X  else
  683. X    {
  684. X      /*
  685. X       * old style command line (position dependent)
  686. X       */
  687. X      fprintf(stderr, "Old style command line no longer supported\n");
  688. X      fprintf(stderr, "Please convert:\n");
  689. X      fprintf(stderr, "old: Ra Dcl Scale Title Maglim Labellim\n");
  690. X      fprintf(stderr, "new: -r Ra -d Dcl -s Scale -t Title\n");
  691. X    }
  692. X  return (TRUE);
  693. X}
  694. X
  695. Xdie(a,b)
  696. X     char *a, *b;
  697. X{
  698. X  /* Currently only Gdos needs this, there appl_exit() is always necessary */
  699. X#ifdef ATARI_ST
  700. X  D_die(a,b);
  701. X#endif
  702. X  fprintf(stderr,"%s: ", progname);
  703. X  fprintf(stderr,a,b);
  704. X  fprintf(stderr,"\n");
  705. X  exit(1);
  706. X}
  707. X
  708. Xdouble htod(s)
  709. X     char *s;
  710. X{
  711. X  /*
  712. X   * htod(str) reads floating point strings of the form {+-}hh.{mm} thus
  713. X   * allowing for fractional values in base 60 (ie, degrees/minutes).
  714. X   */
  715. X  return(ftod(atof(s)));
  716. X}
  717. X
  718. Xdouble ftod(x)
  719. X     double x;
  720. X{
  721. X  int full;
  722. X  full = x;
  723. X  return(full + (x-full)*100.0/60.0);
  724. X}
  725. X
  726. X
  727. X/* dtof(x) undoes ftod */
  728. Xdouble dtof(x)
  729. X     double x;
  730. X{
  731. X  int full;
  732. X  full = x;
  733. X  return(full + (x-full)*60.0/100.0);
  734. X}
  735. X
  736. X/* Adapted from code from Dean Payne deanp@hplsla.hp.com */
  737. X/* Format of each line is
  738. X    variable_name variable_value
  739. Xor    variable_name=variable_value
  740. X
  741. Xvariable_value may be a string which extends to the end of line.
  742. XLines must be 80 chars max.
  743. XComments are anything after a #
  744. XBlank lines are allowed.
  745. X*/
  746. X
  747. Xrc_read(filename)
  748. X     char *filename;
  749. X{
  750. X  FILE *sfile;
  751. X  char sbuf[LINELEN], *var_name, *c_buf;
  752. X  double f_buf;    /* value parsed as double */
  753. X  int i_buf;    /* value parsed as integer */
  754. X  int l_buf;    /* value parsed as TRUE or FALSE */
  755. X  int ret_code, var_type;
  756. X
  757. X  
  758. X  if ((sfile = fopen(filename, READMODE)) == OPENFAIL) return(FALSE);
  759. X
  760. X  fgets(sbuf, LINELEN, sfile);
  761. X  if (!(strcmp(sbuf,
  762. X          "#mapwin format 1 file: don't edit this line or change order of lines in this file"))) {
  763. X    /* This file is a mapwin file */
  764. X    strncpy(mapwin_file, filename, MAXPATHLEN-1);
  765. X    read_mapwin_file = TRUE;
  766. X    return TRUE;
  767. X  };
  768. X    
  769. X  for (;;) {
  770. X    /* We read the first line into  sbuf above, and will read the next line 
  771. X       at the bottom of the loop */
  772. X
  773. X    if (ferror(sfile)) { fprintf(stderr, "file read error\n"); break; }
  774. X    if (feof(sfile)) break;
  775. X    
  776. X    if (!parse_line(sbuf, &var_name, &ret_code, &var_type,
  777. X            &c_buf, &f_buf, &i_buf, &l_buf)) {
  778. X      /* Not recognized by parse routine,
  779. X     see if ident_rc can recognize it */
  780. X      if (!(ident_rc(var_name, c_buf))) {
  781. X    fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
  782. X    help_vars(var_name);
  783. X      }
  784. X    } else
  785. X      switch (ret_code) {
  786. X      case TINT:
  787. X    fprintf(stderr, "int = %d\n", i_buf);
  788. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  789. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  790. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  791. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  792. X    break;
  793. X      case TFLO:
  794. X    fprintf(stderr, "flo = %f\n", f_buf);
  795. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  796. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  797. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  798. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  799. X    break;
  800. X      case TBOOL:
  801. X    fprintf(stderr, "bool = %d\n", l_buf);
  802. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  803. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  804. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  805. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  806. X    break;
  807. X      case TNONE:
  808. X    fprintf(stderr, "none = %s\n", c_buf);
  809. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  810. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  811. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  812. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  813. X    break;
  814. X      case TCHAR:
  815. X    fprintf(stderr, "char = %s\n", c_buf);
  816. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  817. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  818. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  819. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  820. X    break;
  821. X      case R_NONE:
  822. X    /* blank line */
  823. X    break;
  824. X      case END_INPUT:
  825. X    return TRUE;
  826. X    break;
  827. X      case EXIT:
  828. X    exit(0);
  829. X    break;
  830. X      case HELP_ME:
  831. X    help_vars("");
  832. X    break;
  833. X      case WRITE_RC_FILE:
  834. X    {
  835. X      FILE *tfile;
  836. X
  837. X      if ((tfile = fopen(c_buf, "w")) != NULL)
  838. X        if (rc_write(tfile)) {
  839. X          fclose(tfile);
  840. X          printf("wrote %s\n", c_buf);
  841. X        };
  842. X    };
  843. X    break;
  844. X      default:
  845. X    /* Identified but not special to this routine,
  846. X       try to set variables */
  847. X    if (!set_varvals(var_name, ret_code, var_type,
  848. X            c_buf, f_buf, i_buf, l_buf)) {
  849. X      fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
  850. X      help_vars(var_name);
  851. X    };
  852. X    break;
  853. X      };
  854. X
  855. X    /* Always call ident_rc */
  856. X    ident_rc(var_name, c_buf);
  857. X
  858. X
  859. X    fgets(sbuf, LINELEN, sfile);
  860. X  }
  861. X  fclose(sfile);
  862. X  return (TRUE);
  863. X}
  864. X
  865. X
  866. Xrc_write(tfile)
  867. XFILE *tfile;
  868. X{
  869. X  int i;
  870. X
  871. X  fprintf(tfile, "ra = %g\n", dtof(ra / 15.0));
  872. X  fprintf(tfile, "dec = %g\n", dtof(de));
  873. X  fprintf(tfile, "scale = %g\n", sc);
  874. X  if (use_lbllim)
  875. X    fprintf(tfile, "namelim = %g\n", all_lbllim);
  876. X  if (use_gklim)
  877. X    fprintf(tfile, "gklim = %g\n", all_gklim);
  878. X  if (use_maglim)
  879. X    fprintf(tfile, "maglim = %g\n", all_maglim);
  880. X
  881. X  fprintf(tfile, "title = %s\n", title);
  882. X
  883. X  for (i = 0; i < nummapfiles; i++)
  884. X    fprintf(tfile, "mapfile = %s %s\n", mapfiles[i], inv_ftypes[mapftypes[i]]);
  885. X
  886. X  fprintf(tfile, "constfile = %s\n", constfile);
  887. X  fprintf(tfile, "boundfile = %s\n", boundfile);
  888. X  fprintf(tfile, "patternfile = %s\n", patternfile);
  889. X  fprintf(tfile, "constlnamefile = %s\n", cnamefile);
  890. X
  891. X  for (i = 0; i < numlayers; i++)
  892. X    fprintf(tfile, "all_layer = %s\n", inv_layrs[all_layer[i]]);
  893. X
  894. X  fprintf(tfile, "projection_mode = %s\n", inv_projs[all_proj_mode]);
  895. X
  896. X  fprintf(tfile, "chart_type = %s\n", inv_ctypes[chart_type]);
  897. X
  898. X  fprintf(tfile, "invert = %s\n", all_invert ? "true" : "false");
  899. X
  900. X  if (use_vmin)
  901. X    fprintf(tfile, "vrange %g %g\n", all_vmin, all_vmax);
  902. X
  903. X  if (use_rstep)
  904. X    fprintf(tfile, "grid %g %g %g %g\n", dtof(all_rstep/15.0), dtof(all_dstep),
  905. X        dtof(all_rstrt/15.0), dtof(all_dstrt));
  906. X
  907. X  if (precess)
  908. X    fprintf(tfile, "precess_to %g\n", to_precess);
  909. X
  910. X  i = ferror(tfile);
  911. X  return !i;
  912. X} 
  913. X  
  914. X
  915. Xset_varvals(var_name, ret_code, var_type, c_buf, f_buf, i_buf, l_buf)
  916. X     char *var_name;
  917. X     int ret_code, var_type;
  918. X     char *c_buf;
  919. X     double f_buf;    /* value parsed as double */
  920. X     int i_buf;    /* value parsed as integer */
  921. X     int l_buf;    /* value parsed as TRUE or FALSE */
  922. X{
  923. X  int i;
  924. X  static int nufiles = 0;
  925. X  static int nmapfs = 0;
  926. X  static int nlays = 0;
  927. X  double varmag, varrange;
  928. X  int good_flag;
  929. X  char tbuf1[LINELEN], tbuf2[LINELEN], tbuf3[LINELEN], tbuf4[LINELEN];
  930. X
  931. X
  932. X  good_flag = FALSE;
  933. X
  934. X  switch (ret_code) {
  935. X  case R_RA:
  936. X    ra = htod(c_buf)*15.0;
  937. X    good_flag = TRUE; 
  938. X    break;
  939. X  case R_DEC:
  940. X    de = htod(c_buf); 
  941. X    good_flag = TRUE; 
  942. X    break;
  943. X  case R_SCALE:
  944. X    sc = f_buf; 
  945. X    good_flag = TRUE; 
  946. X    break;
  947. X  case R_NAMELIM:
  948. X    all_lbllim = f_buf; 
  949. X    use_lbllim = TRUE;
  950. X    good_flag = TRUE; 
  951. X    break;
  952. X  case R_MAGLIM:
  953. X    all_maglim = f_buf; 
  954. X    use_maglim = TRUE;
  955. X    good_flag = TRUE; 
  956. X    break;
  957. X  case R_GKLIM:
  958. X    all_gklim = f_buf; 
  959. X    use_gklim = TRUE;
  960. X    good_flag = TRUE; 
  961. X    break;
  962. X  case R_TITLE:
  963. X    strcpy(a_title, c_buf); 
  964. X    title = a_title; 
  965. X    good_flag = TRUE; 
  966. X    break;
  967. X  case R_STARFILE:
  968. X    strcpy(a_starfile, c_buf);  
  969. X    mapfiles[YALEF] = a_starfile;
  970. X    good_flag = TRUE; 
  971. X    break;
  972. X  case R_INDEXFILE:
  973. X    strcpy(a_indexfile, c_buf);
  974. X    mapfiles[INDXF] = a_indexfile;
  975. X    good_flag = TRUE; 
  976. X    break;
  977. X  case R_NEBFILE:
  978. X    strcpy(a_nebfile, c_buf); 
  979. X    mapfiles[NEBF] = a_nebfile;
  980. X    good_flag = TRUE; 
  981. X    break;
  982. X  case R_PLANETFILE:
  983. X    strcpy(a_planetfile, c_buf); 
  984. X    mapfiles[PLANF] = a_planetfile;
  985. X    good_flag = TRUE; 
  986. X    break;
  987. X  case R_USERFILE:
  988. X    if (nummapfiles == MAXMAPFILES) {
  989. X      fprintf(stderr, "Too many user files\n");
  990. X    } else {
  991. X      i = sscanf(c_buf, "%s %s", a_userfile[nufiles], tbuf1);
  992. X      if ((i == 2) && tr_fty(tbuf1))    /* There's a type specified */
  993. X    mapftypes[nummapfiles] = tr_fty(tbuf1);
  994. X      else mapftypes[nummapfiles] = LINEREAD;
  995. X      
  996. X      mapfiles[nummapfiles] = a_userfile[nufiles];
  997. X      nufiles++;
  998. X      nummapfiles++;
  999. X    }
  1000. X    good_flag = TRUE;
  1001. X    break;
  1002. X  case R_MAPFILE:
  1003. X    if (nmapfs >= MAXMAPFILES)
  1004. X      fprintf(stderr, "Too many user files\n");
  1005. X    else {
  1006. X      if (nmapfs == 0) {
  1007. X    /* reset mapfiles pointers */
  1008. X    for (i = 0; i < MAXMAPFILES; i++)
  1009. X      mapfiles[i] = a_userfile[i];
  1010. X      };
  1011. X
  1012. X      i = sscanf(c_buf, "%s %s", a_userfile[nmapfs], tbuf1);
  1013. X      if ((i == 2) && tr_fty(tbuf1))    /* There's a type specified */
  1014. X    mapftypes[nmapfs] = tr_fty(tbuf1);
  1015. X      else mapftypes[nmapfs] = LINEREAD;
  1016. X      
  1017. X      mapfiles[nmapfs] = a_userfile[nmapfs];
  1018. X      
  1019. X      nummapfiles = ++nmapfs;
  1020. X    }
  1021. X    good_flag = TRUE;
  1022. X    break;
  1023. X  case R_CONSTFILE:
  1024. X    strcpy(a_constfile, c_buf);
  1025. X    constfile = a_constfile; 
  1026. X    good_flag = TRUE; 
  1027. X    break;
  1028. X  case R_FINDCONST:
  1029. X    findconst(c_buf); 
  1030. X    good_flag = TRUE; 
  1031. X    break;
  1032. X  case R_BOUNDFILE:
  1033. X    strcpy(a_boundfile, c_buf);
  1034. X    boundfile = a_boundfile; 
  1035. X    good_flag = TRUE; 
  1036. X    break;
  1037. X  case R_PATTERNFILE:
  1038. X    strcpy(a_patternfile, c_buf);
  1039. X    patternfile = a_patternfile; 
  1040. X    good_flag = TRUE; 
  1041. X    break;
  1042. X  case R_CONSTLNAMEFILE:
  1043. X    strcpy(a_cnamefile, c_buf);
  1044. X    cnamefile = a_cnamefile; 
  1045. X    good_flag = TRUE; 
  1046. X    break;
  1047. X  case R_LAYERS:
  1048. X    if (nlays >= MAXLAYRS)
  1049. X      fprintf(stderr, "Too many user layers\n");
  1050. X    else {
  1051. X      if (i = tr_layr(c_buf)) {
  1052. X    all_layer[nlays] = i;
  1053. X    numlayers = ++nlays;
  1054. X      }
  1055. X    }
  1056. X    good_flag = TRUE;
  1057. X    break;
  1058. X  case R_POLARMODE:
  1059. X    if (l_buf) all_proj_mode = STEREOGR; 
  1060. X    good_flag = TRUE; 
  1061. X    break;
  1062. X  case R_BIGFLAG:
  1063. X    if (l_buf) chart_type = FULLPAGE; 
  1064. X    good_flag = TRUE; 
  1065. X    break;
  1066. X  case R_PROJECTION_MODE:
  1067. X    if (i = tr_pmode(c_buf)) {
  1068. X      all_proj_mode = i;
  1069. X    }
  1070. X    good_flag = TRUE;
  1071. X    break;
  1072. X  case R_INVERT:
  1073. X    all_invert = l_buf; 
  1074. X    good_flag = TRUE; 
  1075. X    break;
  1076. X  case R_CHART_TYPE:
  1077. X    if (i = tr_ctype(c_buf)) {
  1078. X      chart_type = i;
  1079. X    }
  1080. X    good_flag = TRUE;
  1081. X    break;
  1082. X  case R_VRANGE:
  1083. X    i = sscanf(c_buf, "%lf %lf", &all_vmin, &all_vmax);
  1084. X    use_vmin = (i == 2);
  1085. X    good_flag = TRUE;
  1086. X    break;
  1087. X  case R_VMAGS:
  1088. X    i = sscanf(c_buf, "%lf %lf", &varmag, &varrange);
  1089. X    if (i == 2) {
  1090. X      use_vmin = TRUE;
  1091. X      all_vmin = varmag - varrange;
  1092. X      all_vmax = varmag + varrange;
  1093. X    }
  1094. X    good_flag = TRUE;
  1095. X    break;
  1096. X  case R_GRID:
  1097. X    i = sscanf(c_buf, "%s %s %s %s", tbuf1, tbuf2, tbuf3, tbuf4);
  1098. X    all_rstep = htod(tbuf1)*15.0;
  1099. X    all_dstep = htod(tbuf2);
  1100. X    all_rstrt = htod(tbuf3)*15.0;
  1101. X    all_dstrt = htod(tbuf4);
  1102. X    use_rstep = (i > 1);
  1103. X    good_flag = TRUE;
  1104. X    break;
  1105. X  case R_NOGRID:
  1106. X    no_ra_grid = no_dec_grid = l_buf; 
  1107. X    good_flag = TRUE; 
  1108. X    break;
  1109. X  case R_NOGRID_RA:
  1110. X    no_ra_grid = l_buf; 
  1111. X    good_flag = TRUE; 
  1112. X    break;
  1113. X  case R_NOGRID_DEC:
  1114. X    no_dec_grid = l_buf; 
  1115. X    good_flag = TRUE; 
  1116. X    break;
  1117. X  case R_NOMAGLBLS:
  1118. X    nomaglbls = l_buf; 
  1119. X    good_flag = TRUE; 
  1120. X    break;
  1121. X  case R_PRECESS_TO:
  1122. X    to_precess = f_buf;
  1123. X    precess = TRUE;
  1124. X    good_flag = TRUE;
  1125. X    break;
  1126. X  case R_DRIVER_CONTROL:
  1127. X    D_control_arg(c_buf);
  1128. X    good_flag = TRUE;
  1129. X    break;
  1130. X  case R_WRITE_MAPWIN_FILE:
  1131. X    write_mapwin_file = TRUE;
  1132. X    strncpy(mapwin_file, c_buf, MAXPATHLEN-1);
  1133. X    good_flag = TRUE;
  1134. X    break;
  1135. X  case R_READ_MAPWIN_FILE:
  1136. X    read_mapwin_file = TRUE;
  1137. X    strncpy(mapwin_file, c_buf, MAXPATHLEN-1);
  1138. X    good_flag = TRUE;
  1139. X    break;
  1140. X  default:
  1141. X    break;
  1142. X  };
  1143. X
  1144. X  return good_flag;
  1145. X}
  1146. X
  1147. X
  1148. Xint tr_layr(s)
  1149. X     char *s;
  1150. X{
  1151. X  int i;
  1152. X
  1153. X  for (i = 0; s[i]; i++)
  1154. X    if (isupper(s[i]))
  1155. X      s[i] = tolower(s[i]);
  1156. X
  1157. X  if(!strcmp(s, "outline")) return OUTLINE;
  1158. X  else if (!strcmp(s, "ra_grid")) return RA_GRID;
  1159. X  else if (!strcmp(s, "dec_grid")) return DEC_GRID;
  1160. X  else if (!strcmp(s, "ecliptic")) return ECLIPTIC;
  1161. X  else if (!strcmp(s, "boundaries")) return BOUNDARIES;
  1162. X  else if (!strcmp(s, "patterns")) return PATTERNS;
  1163. X  else if (!strcmp(s, "constlnames")) return CONSTLNAMES;
  1164. X  else if (!strcmp(s, "allfiles")) return ALLFILES;
  1165. X  else if (!strcmp(s, "allglyphs")) return ALLGLYPHS;
  1166. X  else if (!strcmp(s, "allnames")) return ALLNAMES;
  1167. X  else if (!strcmp(s, "allmaglbls")) return ALLMAGLBLS;
  1168. X  else if (!strcmp(s, "allvectors")) return ALLVECTORS;
  1169. X  else if (!strcmp(s, "allareas")) return ALLAREAS;
  1170. X  else if (!strcmp(s, "legends")) return LEGENDS;
  1171. X  else return 0;
  1172. X}
  1173. X
  1174. X
  1175. Xint tr_pmode(s)
  1176. X     char *s;
  1177. X{
  1178. X  int i;
  1179. X
  1180. X  for (i = 0; s[i]; i++)
  1181. X    if (isupper(s[i]))
  1182. X      s[i] = tolower(s[i]);
  1183. X
  1184. X  if(!strcmp(s, "stereogr")) return STEREOGR;
  1185. X  else if(!strcmp(s, "stereographic")) return STEREOGR;
  1186. X  else if (!strcmp(s, "sansons")) return SANSONS;
  1187. X  else if (!strcmp(s, "gnomonic")) return GNOMONIC;
  1188. X  else if (!strcmp(s, "orthogr")) return ORTHOGR;
  1189. X  else if (!strcmp(s, "orthographic")) return ORTHOGR;
  1190. X  else if (!strcmp(s, "rectangular")) return RECTANGULAR;
  1191. X  else return 0;
  1192. X}
  1193. X
  1194. X
  1195. Xint tr_ctype(s)
  1196. X     char *s;
  1197. X{
  1198. X  int i;
  1199. X  for (i = 0; s[i]; i++)
  1200. X    if (isupper(s[i]))
  1201. X      s[i] = tolower(s[i]);
  1202. X
  1203. X  if(!strcmp(s, "fullpage")) return FULLPAGE;
  1204. X  else if (!strcmp(s, "threepart")) return THREEPART;
  1205. X  else return 0;
  1206. X}
  1207. X
  1208. Xint tr_fty(s)
  1209. X     char *s;
  1210. X{
  1211. X  int i;
  1212. X
  1213. X  for (i = 0; s[i]; i++)
  1214. X    if (isupper(s[i]))
  1215. X      s[i] = tolower(s[i]);
  1216. X
  1217. X  if(!strcmp(s, "lineread")) return LINEREAD;
  1218. X  else if (!strcmp(s, "indextype")) return INDEXTYPE;
  1219. X  else if (!strcmp(s, "binfull")) return BINFULL;
  1220. X  else if (!strcmp(s, "binobj")) return BINOBJ;
  1221. X  else if (!strcmp(s, "binstar")) return BINSTAR;
  1222. X/*  else if (!strcmp(s, "saoformat")) return SAOFORMAT;*/
  1223. X  else if (!strcmp(s, "gsc")) return GSCTYPE;
  1224. X  else return 0;
  1225. X}
  1226. X
  1227. X
  1228. X
  1229. Xstatic char title_string[LINELEN];
  1230. X
  1231. Xfindconst(tag)
  1232. X     char *tag;
  1233. X{
  1234. X/*
  1235. X * lookup "con.locs" for a matching tag, and then substitute initial values
  1236. X * for ra, decl, scale, and label. File layout follows:
  1237. X *
  1238. X * com  13    25   10   Coma Bereneces
  1239. X * cor  15.45 28   10   Corona Borealis
  1240. X * 0....+....1....+....2....+....3
  1241. X */
  1242. X  FILE *cfile;
  1243. X  int taglen;
  1244. X  char cbuf[LINELEN+1];
  1245. X  int i;
  1246. X  
  1247. X  if ((cfile = fopen(constfile, "r")) == NULL)
  1248. X    die("open fail on '%s'", constfile);
  1249. X  taglen = strlen(tag);
  1250. X  if ((taglen < 3) || (taglen > 4))
  1251. X    die("constellation name must be three or four characters","");
  1252. X  for (;;)
  1253. X    {
  1254. X      fgets(cbuf, LINELEN, cfile);
  1255. X      if (ferror(cfile)) die("read error in '%s'", constfile);
  1256. X      if (feof(cfile)) break;
  1257. X      if (strncmp(tag, cbuf, taglen) == 0)    /* FOUND */
  1258. X    {    
  1259. X      if (4!=sscanf(cbuf,"%*5s%lf%lf%lf %[^\n]",
  1260. X            &ra, &de, &sc, title_string))
  1261. X        die("bogus line in constellation file: \"%s\"", cbuf);
  1262. X
  1263. X      ra    = ftod(ra)*15.0;
  1264. X      de    = ftod(de);
  1265. X      
  1266. X      /* remove trailing \n */
  1267. X      i = strlen(title_string);
  1268. X      if (title_string[i-1] == '\n') title_string[i-1] = '\0';
  1269. X      title = title_string;
  1270. X      return;
  1271. X    }
  1272. X    }
  1273. X  die("Constellation '%s' not found", tag);
  1274. X}
  1275. X
  1276. X/* check validity of win structure */
  1277. Xchartparms(win)
  1278. X     mapwindow *win;
  1279. X{
  1280. X  double maxdl;
  1281. X
  1282. X  /*
  1283. X   * check for bogus ra, decl, or scale
  1284. X   */
  1285. X  if ((win->racen >= 360.0) || (win->racen < 0.0))
  1286. X    die("right ascension out of range","");
  1287. X  if ((win->dlcen > 90.0) || (win->dlcen < -90.0))
  1288. X    die("declination out of range","");
  1289. X  if (win->scale < 0.0)
  1290. X    die("scale negative","");
  1291. X
  1292. X  /*
  1293. X   * check for pole wrapping and do a potential clip
  1294. X   */
  1295. X  if (win->proj_mode == SANSONS) {
  1296. X    maxdl = (90.0 - fabs(win->dlcen))*2.0;
  1297. X    if (win->scale > maxdl) win->scale = maxdl;
  1298. X    if (win->scale <= 0.0) { /* North pole is included in chart */
  1299. X      return(FALSE);
  1300. X    }
  1301. X  };
  1302. X
  1303. X      return(TRUE);
  1304. X}
  1305. X
  1306. X
  1307. X
  1308. X/* Dump current mapwin information to file. */
  1309. Xwrite_mfile(mfile)
  1310. X     FILE *mfile;
  1311. X{
  1312. X  int i, j;
  1313. X  
  1314. X  /* Tag file as being mapwin format */
  1315. X  fprintf(mfile,
  1316. X      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n");
  1317. X  /* Write the title */
  1318. X  fprintf(mfile, "title=%s\n", title);
  1319. X
  1320. X  /* write number of mapwins */
  1321. X  fprintf(mfile, "numwins=%d\n", numwins);
  1322. X  for (i = 0; i < numwins; i++) {
  1323. X    fprintf(mfile, "mapwin=%d\n",i);
  1324. X    
  1325. X    fprintf(mfile, "width=%d\n", mapwin[i]->width);
  1326. X    fprintf(mfile, "height=%d\n", mapwin[i]->height);
  1327. X    fprintf(mfile, "x_offset=%d\n", mapwin[i]->x_offset);
  1328. X    fprintf(mfile, "y_offset=%d\n", mapwin[i]->y_offset);
  1329. X    
  1330. X    fprintf(mfile, "maglim=%.10f\n", mapwin[i]->maglim);
  1331. X    fprintf(mfile, "lbllim=%.10f\n", mapwin[i]->lbllim);
  1332. X    fprintf(mfile, "gklim=%.10f\n", mapwin[i]->gklim);
  1333. X    
  1334. X    
  1335. X    fprintf(mfile, "map_type=%d\n", mapwin[i]->map_type);
  1336. X    
  1337. X    
  1338. X    fprintf(mfile, "tag=%d\n", mapwin[i]->tag);
  1339. X    
  1340. X    fprintf(mfile, "tag_field=%s\n", mapwin[i]->tag_field);
  1341. X    
  1342. X    
  1343. X    fprintf(mfile, "proj_mode=%d\n", mapwin[i]->proj_mode);
  1344. X    
  1345. X    
  1346. X    fprintf(mfile, "draw_ragrid=%d\n", mapwin[i]->draw_ragrid);
  1347. X    fprintf(mfile, "draw_decgrid=%d\n", mapwin[i]->draw_decgrid);
  1348. X    
  1349. X    fprintf(mfile, "ra_step=%.10f\n", mapwin[i]->ra_step);
  1350. X    fprintf(mfile, "dec_step=%.10f\n", mapwin[i]->dec_step);
  1351. X    
  1352. X    fprintf(mfile, "ra_strt=%.10f\n", mapwin[i]->ra_strt);
  1353. X    fprintf(mfile, "dec_strt=%.10f\n", mapwin[i]->dec_strt);
  1354. X    
  1355. X    
  1356. X    fprintf(mfile, "invert=%d\n", mapwin[i]->invert);
  1357. X    
  1358. X    fprintf(mfile, "racen=%.10f\n", mapwin[i]->racen);
  1359. X    fprintf(mfile, "dlcen=%.10f\n", mapwin[i]->dlcen);
  1360. X    fprintf(mfile, "scale=%.10f\n", mapwin[i]->scale);
  1361. X    
  1362. X    fprintf(mfile, "c_scale=%.10f\n", mapwin[i]->c_scale);
  1363. X    
  1364. X    fprintf(mfile, "nlayers=%d\n", mapwin[i]->nlayers);
  1365. X    for (j = 0; j < mapwin[i]->nlayers; j++)
  1366. X      fprintf(mfile, "layer[%d] = %d\n", j, mapwin[i]->layer[j]);  
  1367. X    
  1368. X    fprintf(mfile, "numfiles=%d\n", mapwin[i]->numfiles);
  1369. X    for (j = 0; j < mapwin[i]->numfiles; j++) {
  1370. X      fprintf(mfile, "file=%d\n", j);
  1371. X      fprintf(mfile, "name=%s\n",mapwin[i]->file[j].name);
  1372. X      fprintf(mfile, "type=%d\n", mapwin[i]->file[j].type);
  1373. X      fprintf(mfile, "maglim=%.10f\n", mapwin[i]->file[j].maglim);
  1374. X      fprintf(mfile, "lbllim=%.10f\n", mapwin[i]->file[j].lbllim);
  1375. X      fprintf(mfile, "gklim=%.10f\n", mapwin[i]->file[j].gklim);
  1376. X      fprintf(mfile, "draw_maglbl=%d\n", mapwin[i]->file[j].draw_maglbl);
  1377. X      fprintf(mfile, "maglmin=%.10f\n", mapwin[i]->file[j].maglmin);
  1378. X      fprintf(mfile, "maglmax=%.10f\n", mapwin[i]->file[j].maglmax);
  1379. X    }
  1380. X  }
  1381. X  
  1382. X  
  1383. X  /* Tag file as being mapwin format */
  1384. X  fprintf(mfile,
  1385. X      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n");
  1386. X}
  1387. END_OF_FILE
  1388. if test 33377 -ne `wc -c <'starchart/starmain.c'`; then
  1389.     echo shar: \"'starchart/starmain.c'\" unpacked with wrong size!
  1390. fi
  1391. # end of 'starchart/starmain.c'
  1392. fi
  1393. echo shar: End of archive 23 \(of 32\).
  1394. cp /dev/null ark23isdone
  1395. MISSING=""
  1396. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1397.     if test ! -f ark${I}isdone ; then
  1398.     MISSING="${MISSING} ${I}"
  1399.     fi
  1400. done
  1401. if test "${MISSING}" = "" ; then
  1402.     echo You have unpacked all 32 archives.
  1403.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1404. else
  1405.     echo You still need to unpack the following archives:
  1406.     echo "        " ${MISSING}
  1407. fi
  1408. ##  End of shell archive.
  1409. exit 0
  1410.  
  1411.